package com.oauth.controller;

 import com.oauth.vo.CustomUser;
 import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * Created by Fant.J.
 */
@Component
public class MyUserDetailsService implements UserDetailsService {

//    @Reference(version = "2.0.0")
//    private UserService userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        String passwd = "";
        System.out.println("收到的账号"+username);
//        if (CheckFormat.isEmail(username)){
//            passwd = userService.selectPasswdByEmail(username);
//        }else if (CheckFormat.isPhone(username)){
//            passwd = userService.selectPasswdByPhone(username);
//        }else {
//            throw new RuntimeException("登录账号不存在");
//        }
        System.out.println("查到的密码"+passwd);
        return new CustomUser("匿名者",username,"https://www.google.cn/favicon.ico", AuthorityUtils.commaSeparatedStringToAuthorityList("admin,user,root"));

//        return new CustomUser(username, passwd, AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
    }
}

